﻿using global::Zhaoxi.AgiletyFramework.DbModels.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Zhaoxi.AgiletyFramework.DbModels;
using Zhaoxi.AgiletyFramework.IBusinessServices;
namespace Zhaoxi.AgiletyFramework.WebApi.Controllers;

/// <summary>
/// 用户控制器
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
    private readonly AgiletyDbContext agiletyDbContext;

    private readonly IUserService _userService;

    public UserController(IUserService userService, AgiletyDbContext AgiletyDbContext)
    {
        _userService = userService;
        agiletyDbContext = AgiletyDbContext;
    }


    // GET: api/User
    /// <summary>
    /// 获取所有用户信息
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public async Task<ActionResult<IEnumerable<UserEntity>>> GetAllUsers()
    {
        var users = await agiletyDbContext.UserEntities.ToListAsync();
        _userService.Query();
        return Ok(users); // 自动将用户列表序列化为 JSON
    }
}
